﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.Issues.CapturedByBountyHuntersIssueBehavior
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.MapEvents;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.Issues
{
  public class CapturedByBountyHuntersIssueBehavior : CampaignBehaviorBase
  {
    private const IssueBase.IssueFrequency CapturedByBountyHuntersIssueFrequency = IssueBase.IssueFrequency.Common;
    private const float ValidHideoutDistance = 55f;

    public override void RegisterEvents()
    {
      CampaignEvents.OnCheckForIssueEvent.AddNonSerializedListener((object) this, new Action<Hero>(this.OnCheckForIssue));
    }

    public override void SyncData(IDataStore dataStore)
    {
    }

    private bool ConditionsHold(Hero issueGiver, out Settlement selectedHideout)
    {
      selectedHideout = (Settlement) null;
      if (issueGiver.IsLord || issueGiver.IsNotable && issueGiver.CurrentSettlement == null || !issueGiver.IsGangLeader)
        return false;
      selectedHideout = this.FindSuitableHideout(issueGiver);
      CharacterObject characterObject = MBObjectManager.Instance.GetObject<CharacterObject>("looter");
      return selectedHideout != null && characterObject != null;
    }

    private Settlement FindSuitableHideout(Hero issueGiver)
    {
      Settlement suitableHideout = (Settlement) null;
      float num = float.MaxValue;
      foreach (Hideout hideout in Campaign.Current.AllHideouts.Where<Hideout>((Func<Hideout, bool>) (t => t.IsInfested)))
      {
        float distance;
        if (!Campaign.Current.BusyHideouts.Contains(hideout.Settlement) && Campaign.Current.Models.MapDistanceModel.GetDistance(issueGiver.GetMapPoint(), hideout.Settlement, 55.0 < (double) num ? 55f : num, out distance) && (double) distance < (double) num)
        {
          num = distance;
          suitableHideout = hideout.Settlement;
        }
      }
      return suitableHideout;
    }

    public void OnCheckForIssue(Hero hero)
    {
      Settlement selectedHideout;
      if (this.ConditionsHold(hero, out selectedHideout))
        Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(new PotentialIssueData.StartIssueDelegate(this.OnSelected), typeof (CapturedByBountyHuntersIssueBehavior.CapturedByBountyHuntersIssue), IssueBase.IssueFrequency.Common, (object) selectedHideout));
      else
        Campaign.Current.IssueManager.AddPotentialIssueData(hero, new PotentialIssueData(typeof (CapturedByBountyHuntersIssueBehavior.CapturedByBountyHuntersIssue), IssueBase.IssueFrequency.Common));
    }

    private IssueBase OnSelected(in PotentialIssueData pid, Hero issueOwner)
    {
      return (IssueBase) new CapturedByBountyHuntersIssueBehavior.CapturedByBountyHuntersIssue(issueOwner, pid.RelatedObject as Settlement);
    }

    public class CapturedByBountyHuntersIssue : IssueBase
    {
      private const int CompanionRequiredSkillLevel = 120;
      private const int IssueDuration = 15;
      private const int QuestTimeLimit = 30;
      [SaveableField(100)]
      private Settlement _hideout;

      internal static void AutoGeneratedStaticCollectObjectsCapturedByBountyHuntersIssue(
        object o,
        List<object> collectedObjects)
      {
        ((MBObjectBase) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
      }

      protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
      {
        base.AutoGeneratedInstanceCollectObjects(collectedObjects);
        collectedObjects.Add((object) this._hideout);
      }

      internal static object AutoGeneratedGetMemberValue_hideout(object o)
      {
        return (object) ((CapturedByBountyHuntersIssueBehavior.CapturedByBountyHuntersIssue) o)._hideout;
      }

      public override int AlternativeSolutionBaseNeededMenCount => 10;

      protected override int AlternativeSolutionBaseDurationInDaysInternal
      {
        get => Math.Max(5, 4 + MathF.Ceiling(6f * this.IssueDifficultyMultiplier));
      }

      protected override int RewardGold => 3000;

      public override IssueBase.AlternativeSolutionScaleFlag AlternativeSolutionScaleFlags
      {
        get
        {
          return IssueBase.AlternativeSolutionScaleFlag.Casualties | IssueBase.AlternativeSolutionScaleFlag.FailureRisk;
        }
      }

      public override TextObject IssueBriefByIssueGiver
      {
        get
        {
          return new TextObject("{=QtmPWQ5a}Some of my lads have gone missing. I've got a witness who says they'd gotten themselves dead drunk drinking with another band in these parts who turned out to be filthy bounty hunters. Now my boys are all trussed up, and these treacherous animals aim to turn them in for the bounty.[if:convo_annoyed][ib:closed]");
        }
      }

      public override TextObject IssueAcceptByPlayer
      {
        get => new TextObject("{=tZqbrlV9}How can I help you?");
      }

      public override TextObject IssueQuestSolutionExplanationByIssueGiver
      {
        get
        {
          TextObject explanationByIssueGiver = new TextObject("{=MiVYmiBc}Raid the bounty hunters' hideout and rescue my associates from them. I will make it worth your while, say {GOLD_AMOUNT} denars.[if:convo_mocking_revenge][ib:closed2]");
          explanationByIssueGiver.SetTextVariable("GOLD_AMOUNT", this.RewardGold);
          return explanationByIssueGiver;
        }
      }

      public override TextObject IssueAlternativeSolutionExplanationByIssueGiver
      {
        get
        {
          TextObject explanationByIssueGiver = new TextObject("{=GIkvhuCC}Maybe one of your men who knows a thing or two about scouting, with {TROOP_AMOUNT} good men can deal with these scum. So what do you say?[if:convo_undecided_open]");
          explanationByIssueGiver.SetTextVariable("TROOP_AMOUNT", this.GetTotalAlternativeSolutionNeededMenCount());
          return explanationByIssueGiver;
        }
      }

      public override TextObject IssueQuestSolutionAcceptByPlayer
      {
        get => new TextObject("{=cvWxXGo5}I can do the job.");
      }

      public override TextObject IssueAlternativeSolutionAcceptByPlayer
      {
        get
        {
          return new TextObject("{=AvBNKK5y}Alright, I will have one of my companions go and rescue your associates.");
        }
      }

      public override TextObject IssueAlternativeSolutionResponseByIssueGiver
      {
        get
        {
          return new TextObject("{=9u9OEZ9Y}Splendid. My men will guide your companion to the hideout.");
        }
      }

      public override TextObject IssueDiscussAlternativeSolution
      {
        get
        {
          return new TextObject("{=zwNjgdbi}My boys are getting ready for the battle. I'm pretty sure your men will tip the balance of that fight in our favor. Thank you.");
        }
      }

      public override bool IsThereAlternativeSolution => true;

      public override bool IsThereLordSolution => false;

      public override TextObject Title
      {
        get
        {
          TextObject parent = new TextObject("{=TQyB9rAs}{ISSUE_OWNER.NAME}'s associates captured by bounty hunters.");
          StringHelpers.SetCharacterProperties("ISSUE_OWNER", this.IssueOwner.CharacterObject, parent);
          return parent;
        }
      }

      public override TextObject Description
      {
        get
        {
          TextObject parent = new TextObject("{=HhTTzgLj}{ISSUE_OWNER.LINK}, a gang leader in {ISSUE_SETTLEMENT}, wants us to raid some bounty hunters' hideout and rescue {?ISSUE_OWNER.GENDER}her{?}his{\\?} associates.");
          StringHelpers.SetCharacterProperties("ISSUE_OWNER", this.IssueOwner.CharacterObject, parent);
          parent.SetTextVariable("ISSUE_SETTLEMENT", this.IssueOwner.CurrentSettlement.EncyclopediaLinkWithName);
          return parent;
        }
      }

      public CapturedByBountyHuntersIssue(Hero issueOwner, Settlement hideout)
        : base(issueOwner, CampaignTime.DaysFromNow(15f))
      {
        this._hideout = hideout;
        Campaign.Current.BusyHideouts.Add(this._hideout);
      }

      protected override float GetIssueEffectAmountInternal(IssueEffect issueEffect)
      {
        if (issueEffect == DefaultIssueEffects.SettlementSecurity)
          return 1f;
        return issueEffect == DefaultIssueEffects.IssueOwnerPower ? -0.2f : 0.0f;
      }

      public override (SkillObject, int) GetAlternativeSolutionSkill(Hero hero)
      {
        return (hero.GetSkillValue(DefaultSkills.Scouting) >= hero.GetSkillValue(DefaultSkills.Riding) ? DefaultSkills.Scouting : DefaultSkills.Riding, 120);
      }

      public override bool DoTroopsSatisfyAlternativeSolution(
        TroopRoster troopRoster,
        out TextObject explanation)
      {
        explanation = TextObject.Empty;
        return QuestHelper.CheckRosterForAlternativeSolution(troopRoster, this.GetTotalAlternativeSolutionNeededMenCount(), ref explanation);
      }

      public override bool AlternativeSolutionCondition(out TextObject explanation)
      {
        explanation = TextObject.Empty;
        return QuestHelper.CheckRosterForAlternativeSolution(MobileParty.MainParty.MemberRoster, this.GetTotalAlternativeSolutionNeededMenCount(), ref explanation);
      }

      protected override int CompanionSkillRewardXP
      {
        get => (int) (750.0 + 1000.0 * (double) this.IssueDifficultyMultiplier);
      }

      protected override void AlternativeSolutionEndWithSuccessConsequence()
      {
        this.RelationshipChangeWithIssueOwner = 5;
        this.IssueOwner.AddPower(10f);
        this.IssueOwner.CurrentSettlement.Town.Security += 5f;
      }

      protected override void AlternativeSolutionEndWithFailureConsequence()
      {
        TraitLevelingHelper.OnIssueFailed(this.IssueOwner, new Tuple<TraitObject, int>[1]
        {
          new Tuple<TraitObject, int>(DefaultTraits.Honor, -10)
        });
        this.RelationshipChangeWithIssueOwner = -5;
        this.IssueOwner.AddPower(-10f);
        this.IssueOwner.CurrentSettlement.Town.Security -= 5f;
      }

      protected override TextObject AlternativeSolutionStartLog
      {
        get
        {
          TextObject parent = new TextObject("{=U7sTASN4}{ISSUE_OWNER.LINK}, a gang leader from {QUEST_SETTLEMENT}, has told you that some bounty hunters captured some of {?ISSUE_OWNER.GENDER}her{?}his{\\?} gang members and are holding them in their hideout. {?ISSUE_OWNER.GENDER}She{?}He{\\?} wants them found and rescued. You agreed to send {TROOP_COUNT} of your men along with a {COMPANION.LINK} to find these bounty hunters and rescue {?ISSUE_OWNER.GENDER}her{?}his{\\?} associates. They should be back in {RETURN_DAYS} days.");
          StringHelpers.SetCharacterProperties("ISSUE_OWNER", this.IssueOwner.CharacterObject, parent);
          StringHelpers.SetCharacterProperties("COMPANION", this.AlternativeSolutionHero.CharacterObject, parent);
          parent.SetTextVariable("QUEST_SETTLEMENT", this.IssueOwner.CurrentSettlement.EncyclopediaLinkWithName);
          parent.SetTextVariable("RETURN_DAYS", this.GetTotalAlternativeSolutionDurationInDays());
          parent.SetTextVariable("TROOP_COUNT", this.AlternativeSolutionSentTroops.TotalManCount - 1);
          return parent;
        }
      }

      public override IssueBase.IssueFrequency GetFrequency() => IssueBase.IssueFrequency.Common;

      public override bool IssueStayAliveConditions() => this._hideout.Hideout.IsInfested;

      protected override bool CanPlayerTakeQuestConditions(
        Hero issueGiver,
        out IssueBase.PreconditionFlags flag,
        out Hero relationHero,
        out SkillObject skill)
      {
        skill = (SkillObject) null;
        relationHero = (Hero) null;
        flag = IssueBase.PreconditionFlags.None;
        if ((double) issueGiver.GetRelationWithPlayer() < -10.0)
        {
          flag |= IssueBase.PreconditionFlags.Relation;
          relationHero = issueGiver;
        }
        return flag == IssueBase.PreconditionFlags.None;
      }

      protected override void OnGameLoad()
      {
        if (!MBSaveLoad.IsUpdatingGameVersion || !(MBSaveLoad.LastLoadedGameVersion < ApplicationVersion.FromString("v1.2.9")) || Campaign.Current.BusyHideouts.Contains(this._hideout))
          return;
        Campaign.Current.BusyHideouts.Add(this._hideout);
      }

      protected override void HourlyTick()
      {
      }

      protected override QuestBase GenerateIssueQuest(string questId)
      {
        return (QuestBase) new CapturedByBountyHuntersIssueBehavior.CapturedByBountyHuntersIssueQuest(questId, this.IssueOwner, CampaignTime.DaysFromNow(30f), this.RewardGold, this._hideout);
      }

      protected override void CompleteIssueWithTimedOutConsequences()
      {
      }

      protected override void OnIssueFinalized()
      {
        Campaign.Current.BusyHideouts.Remove(this._hideout);
      }
    }

    public class CapturedByBountyHuntersIssueQuest : QuestBase
    {
      [SaveableField(102)]
      private Settlement _questHideout;

      internal static void AutoGeneratedStaticCollectObjectsCapturedByBountyHuntersIssueQuest(
        object o,
        List<object> collectedObjects)
      {
        ((MBObjectBase) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
      }

      protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
      {
        base.AutoGeneratedInstanceCollectObjects(collectedObjects);
        collectedObjects.Add((object) this._questHideout);
      }

      internal static object AutoGeneratedGetMemberValue_questHideout(object o)
      {
        return (object) ((CapturedByBountyHuntersIssueBehavior.CapturedByBountyHuntersIssueQuest) o)._questHideout;
      }

      public override TextObject Title
      {
        get
        {
          TextObject parent = new TextObject("{=TQyB9rAs}{ISSUE_OWNER.NAME}'s associates captured by bounty hunters.");
          StringHelpers.SetCharacterProperties("ISSUE_OWNER", this.QuestGiver.CharacterObject, parent);
          return parent;
        }
      }

      public override bool IsRemainingTimeHidden => false;

      private TextObject _playerStartsQuestLogText
      {
        get
        {
          TextObject parent = new TextObject("{=P7MZ0hZb}{QUEST_GIVER.LINK}, a gang leader from {QUEST_SETTLEMENT}, has told you that some bounty hunters captured some of {?QUEST_GIVER.GENDER}her{?}his{\\?} gang members and are holding them in their hideout. You told {?QUEST_GIVER.GENDER}her{?}him{\\?} you would find them yourself.");
          StringHelpers.SetCharacterProperties("QUEST_GIVER", this.QuestGiver.CharacterObject, parent);
          parent.SetTextVariable("QUEST_SETTLEMENT", Settlement.CurrentSettlement.EncyclopediaLinkWithName);
          return parent;
        }
      }

      private TextObject _successQuestLogText
      {
        get
        {
          TextObject parent = new TextObject("{=rNDRyFP4}You cleared the hideout and rescued the {QUEST_GIVER.LINK}'s associates. {?QUEST_GIVER.GENDER}She{?}He{\\?} sends you the following letter. \"Thank you for rescuing my men. I'll remember this.\"");
          StringHelpers.SetCharacterProperties("QUEST_GIVER", this.QuestGiver.CharacterObject, parent);
          return parent;
        }
      }

      private TextObject _playerLostTheFightLogText
      {
        get
        {
          TextObject parent = new TextObject("{=nq0qLQ1x}You lost the fight against bounty hunters and failed to rescue the {QUEST_GIVER.LINK}'s men. {?QUEST_GIVER.GENDER}She{?}He{\\?} sends you the following letter. \"I appreciate your effort but it wasn't good enough...\"");
          StringHelpers.SetCharacterProperties("QUEST_GIVER", this.QuestGiver.CharacterObject, parent);
          return parent;
        }
      }

      private TextObject _hideoutClearedBySomeoneElseLogText
      {
        get
        {
          TextObject parent = new TextObject("{=4Bub0GY6}Hideout was cleared by someone else. Your agreement with {QUEST_GIVER.LINK} is canceled.");
          StringHelpers.SetCharacterProperties("QUEST_GIVER", this.QuestGiver.CharacterObject, parent);
          return parent;
        }
      }

      private TextObject _timeOutLogText
      {
        get
        {
          TextObject parent = new TextObject("{=JPAGzEhe}You failed to rescue the {QUEST_GIVER.LINK}'s men in time. {?QUEST_GIVER.GENDER}She{?}He{\\?} sends you the following letter. \"You sat on your heels doing nothing and my men will pay the price. I won't forget this...\"");
          StringHelpers.SetCharacterProperties("QUEST_GIVER", this.QuestGiver.CharacterObject, parent);
          return parent;
        }
      }

      public CapturedByBountyHuntersIssueQuest(
        string questId,
        Hero giverHero,
        CampaignTime duration,
        int rewardGold,
        Settlement hideout)
        : base(questId, giverHero, duration, rewardGold)
      {
        this._questHideout = hideout;
        Campaign.Current.BusyHideouts.Add(this._questHideout);
        this.SetDialogs();
        this.InitializeQuestOnCreation();
      }

      private bool DialogCondition() => Hero.OneToOneConversationHero == this.QuestGiver;

      protected override void SetDialogs()
      {
        this.OfferDialogFlow = DialogFlow.CreateDialogFlow("issue_classic_quest_start").NpcLine(new TextObject("{=BUM63VJq}That's the spirit. My men will tell you how to find the hideout. Rescue those poor captives, and a large sack of silver will be on your way![if:convo_approving][ib:hip]")).Condition(new ConversationSentence.OnConditionDelegate(this.DialogCondition)).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestAcceptedConsequences)).CloseDialog();
        this.DiscussDialogFlow = DialogFlow.CreateDialogFlow("quest_discuss").NpcLine(new TextObject("{=vYCY931w}Any news about my men?")).Condition(new ConversationSentence.OnConditionDelegate(this.DialogCondition)).BeginPlayerOptions().PlayerOption(new TextObject("{=DJcMau0U}Not yet. We are still looking for them.")).NpcLine(new TextObject("{=VZhs6rpG}Well, try to speed it up. Once the bounty hunters turn them in, it'll be too late.")).CloseDialog().PlayerOption(new TextObject("{=LvNTjCtQ}We need more time.")).NpcLine(new TextObject("{=15wCjIBY}Take too much time, and my men will swing from the gallows. Speed it along, will you?")).CloseDialog().EndPlayerOptions();
      }

      private void QuestAcceptedConsequences()
      {
        this.StartQuest();
        this.AddLog(this._playerStartsQuestLogText);
      }

      protected override void InitializeQuestOnGameLoad() => this.SetDialogs();

      protected override void HourlyTick()
      {
      }

      protected override void OnFinalize()
      {
        Campaign.Current.BusyHideouts.Remove(this._questHideout);
      }

      protected override void RegisterEvents()
      {
        CampaignEvents.OnSessionLaunchedEvent.AddNonSerializedListener((object) this, new Action<CampaignGameStarter>(this.OnSessionLaunched));
        CampaignEvents.MapEventEnded.AddNonSerializedListener((object) this, new Action<MapEvent>(this.OnMapEventEnded));
        CampaignEvents.OnSettlementLeftEvent.AddNonSerializedListener((object) this, new Action<MobileParty, Settlement>(this.OnSettlementLeft));
      }

      private void OnSessionLaunched(CampaignGameStarter campaignGameStarter)
      {
        if (!MBSaveLoad.IsUpdatingGameVersion || !(MBSaveLoad.LastLoadedGameVersion < ApplicationVersion.FromString("v1.2.9")))
          return;
        if (!Campaign.Current.BusyHideouts.Contains(this._questHideout))
        {
          Campaign.Current.BusyHideouts.Add(this._questHideout);
        }
        else
        {
          this.CompleteQuestWithCancel();
          Campaign.Current.BusyHideouts.Add(this._questHideout);
        }
      }

      private void OnSettlementLeft(MobileParty party, Settlement settlement)
      {
        if (party != MobileParty.MainParty || settlement != this.QuestGiver.CurrentSettlement)
          return;
        this._questHideout.Hideout.IsSpotted = true;
        this._questHideout.IsVisible = true;
        this.AddTrackedObject((ITrackableCampaignObject) this._questHideout);
        TextObject textObject = new TextObject("{=R9R6imnU}Scouts working for {QUEST_GIVER.NAME} marked the hideout on your map");
        StringHelpers.SetCharacterProperties("QUEST_GIVER", this.QuestGiver.CharacterObject, textObject);
        MBInformationManager.AddQuickInformation(textObject);
      }

      private void OnMapEventEnded(MapEvent mapEvent)
      {
        if (mapEvent.IsPlayerMapEvent)
        {
          if (mapEvent.MapEventSettlement != this._questHideout)
            return;
          if (mapEvent.DefeatedSide == mapEvent.PlayerSide || mapEvent.DefeatedSide == BattleSideEnum.None)
          {
            this.AddLog(this._playerLostTheFightLogText);
            this.FailConsequences(false);
          }
          else
          {
            this.AddLog(this._successQuestLogText);
            this.SuccessConsequences();
          }
        }
        else
        {
          if (this._questHideout.Parties.Count != 0)
            return;
          this.AddLog(this._hideoutClearedBySomeoneElseLogText);
          this.CompleteQuestWithFail();
        }
      }

      private void SuccessConsequences()
      {
        GiveGoldAction.ApplyBetweenCharacters((Hero) null, Hero.MainHero, this.RewardGold);
        this.QuestGiver.AddPower(10f);
        this.RelationshipChangeWithQuestGiver = 5;
        if (this.QuestGiver.CurrentSettlement != null && this.QuestGiver.CurrentSettlement.Town != null)
          this.QuestGiver.CurrentSettlement.Town.Security += 5f;
        TraitLevelingHelper.OnIssueSolvedThroughQuest(this.QuestGiver, new Tuple<TraitObject, int>[1]
        {
          new Tuple<TraitObject, int>(DefaultTraits.Honor, 100)
        });
        this.CompleteQuestWithSuccess();
      }

      private void FailConsequences(bool isTimedOut)
      {
        TraitLevelingHelper.OnIssueFailed(this.QuestGiver, new Tuple<TraitObject, int>[1]
        {
          new Tuple<TraitObject, int>(DefaultTraits.Honor, -10)
        });
        this.RelationshipChangeWithQuestGiver = -5;
        this.QuestGiver.AddPower(-10f);
        if (this.QuestGiver.CurrentSettlement != null && this.QuestGiver.CurrentSettlement.Town != null)
          this.QuestGiver.CurrentSettlement.Town.Security -= 5f;
        if (isTimedOut)
          return;
        this.CompleteQuestWithFail();
      }

      protected override void OnTimedOut()
      {
        this.AddLog(this._timeOutLogText);
        this.FailConsequences(true);
      }
    }

    public class CapturedByBountyHuntersIssueTypeDefiner : SaveableTypeDefiner
    {
      public CapturedByBountyHuntersIssueTypeDefiner()
        : base(580000)
      {
      }

      protected override void DefineClassTypes()
      {
        this.AddClassDefinition(typeof (CapturedByBountyHuntersIssueBehavior.CapturedByBountyHuntersIssue), 1);
        this.AddClassDefinition(typeof (CapturedByBountyHuntersIssueBehavior.CapturedByBountyHuntersIssueQuest), 2);
      }
    }
  }
}
